import { createStore } from "vuex";
import vuexPer from "vuex-persistedstate";
export default createStore({
  state: {
    list: [],
  },
  mutations: {
    add(state, obj) {
      state.list.push(obj);
    },
    del(state, index) {
      state.list.splice(index, 1);
    },
    clear(state, selectVal) {
      // selectVal是从页面传来的选中的要删除的数据
      // 选中删除的逻辑把不删的留下来
      state.list = state.list.filter((item) => {
        return selectVal.includes(item) == false;
      });
      // includes 看数组中是不是包含这个选项
      // 把不删饿的留下来
    },
  },
  actions: {},
  modules: {},
  plugins: [vuexPer()],
});
